package homework0309;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class PWDemo {
    public static void main(String[] args) throws IOException {


        PrintWriter pw = new PrintWriter("pw.txt");
        pw.println("和我在成都的街头走一走，哦哦哦哦..");
        pw.println("直到所有的灯都熄灭了也不停留");
        System.out.println("写出完毕");
        pw.close();


             FileOutputStream fos = new FileOutputStream("pw.txt"); //文件流(低级流)
             OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); //转换流(高级流)
             BufferedWriter bw = new BufferedWriter(osw); //缓冲字符流(高级流)
             bw.write("和我在成都的街头走一走，哦哦哦哦..");
             bw.write("直到所有的灯都熄灭了也不停留");
             System.out.println("写出完毕!");
             bw.close(); //先调用flush()冲水


    }
}
